<div class="dialog sendMsgDlg hidden">
    <div class="box" style="height: 290px;">
        <div class="title">
            <h4 class="fl">发送短信对话框</h4>
            <span class="fr"><a href="#" onclick="closeDialog();">关闭</a></span>
        </div>
        <table class="form-tab">
            <tr>
                <th width="80">手机号码：</th>
                <td>
                    <input type="text" name="rphone" value="{$charge.phone}" />
                </td>
            </tr>
            <tr>
                <th>模板名称：</th>
                <td>
                    <input type="hidden" name="code" value="{$tmpl.code}" />
                    <input disabled="disabled" type="text" value="{$tmpl.name}" />
                </td>
            </tr>
            <tr>
                <th>模板内容：</th>
                <td>{$tmpl.content}</td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;line-height:40px;">
                    <button class="btn btn-highlight" onclick="action_sendMsg();">提交</button>
                    <span>或</span>
                    <a href="#" onclick="closeDialog();" class="linkBtn">放弃</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="dialog sendMsgBatchDlg hidden">
    <div class="box" style="height: 290px;">
        <div class="title">
            <h4 class="fl">发送短信对话框</h4>
            <span class="fr"><a href="#" onclick="closeDialog();">关闭</a></span>
        </div>
        <table class="form-tab">
            <tr>
                <th width="80">发送对象：</th>
                <td>
                    <input disabled="disabled" type="text" name="num" value="" />
                </td>
            </tr>
            <tr>
                <th>模板名称：</th>
                <td>
                    <input type="hidden" name="code" value="{$tmpl.code}" />
                    <input disabled="disabled" type="text" value="{$tmpl.name}" />
                </td>
            </tr>
            <tr>
                <th>模板内容：</th>
                <td>{$tmpl.content}</td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;line-height:40px;">
                    <button class="btn btn-highlight" onclick="action_sendMsgBatch();">提交</button>
                    <span>或</span>
                    <a href="#" onclick="closeDialog();" class="linkBtn">放弃</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<script>

    /* 黑名单相关处理 */
    function action_send(){
        var dataIds = new Array();
        dataIds.push( $("input[name=id]").val() );
        if(dataIds.length==0){
            alert("请选择操作对象");
            return false;
        }
        $(".sendMsgDlg").show();
    }

    function action_sendBatch(){
        var dataIds = new Array();
        $("input[class=checkbox]").each(function () { //由于复选框一般选中的是多个,所以可以循环输出
            if ($(this).is(":checked")) {
                dataIds.push(parseInt($(this).attr("data-id")));
            }
        });
        if (dataIds.length == 0) {
            alert("请选择操作对象");
            return false;
        }
        $("input[name=num]").val(dataIds.length);
        $(".sendMsgBatchDlg").show();
    }

    function action_sendMsgBatch() {

        var dataIds = new Array();
        $("input[class=checkbox]").each(function () { //由于复选框一般选中的是多个,所以可以循环输出
            if ($(this).is(":checked")) {
                dataIds.push(parseInt($(this).attr("data-id")));
            }
        });
        if (dataIds.length == 0) {
            alert("请选择要操作的对象");
            return false;
        }
        var code = $("input[name=code]").val();
        $.ajax({
            url:"/admin/charge/ajax_sendMsgBatch",
            data: {info:dataIds, code:code}, type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("短信发送成功");
                    location.reload();
                }else{
                    alert(data.info);
                }
            }
        });
    }

    /* 发放补贴 */
    function action_sendMsg(){
        var code = $("input[name=code]").val();
        var phone = $("input[name=rphone]").val();
        var dataId = $("input[name=id]").val();
        $.ajax({
            url:"/admin/charge/ajax_sendMsg",
            data: {info:dataId, phone:phone, code:code}, type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("短信发送成功");
                    location.reload();
                }else{
                    console.log(data.info);
                    alert(data.info);
                }
            }
        });
    }

    $(".scroll-table .tbody").scroll(function(){
        $(".scroll-table .thead").scrollLeft($(this).scrollLeft());
    });
</script>